/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Book;

import BookCategory.BookCategoryBean;
import BookType.BookTypeBean;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 *
 * @author mishra
 */
public class ShowBookDetails extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, SQLException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            int aid=Integer.parseInt(request.getParameter("aId"));
            BookBean bb=Book.Query.viewSpecific("book_id", aid);
            BookTypeBean btb=bb.getBookTypeBean();
            BookCategoryBean bcb=btb.getBookCategoryBean();
            
            out.println("<a href = 'javascript:void(0)' onclick='quickClose()'><span id='quickclose'><img src='../../img/close.png'></span></a>");
            out.println("<div id='records'>");
            
            out.println("<div class='rowood'>");
            out.println("<div><b>Book ID :&nbsp; </b>"+bb.getBookId()+"</div>");
            out.println("<div><b>Book Name :&nbsp; </b>"+bb.getBookName()+"</div>");
            out.println("</div>");
            
            out.println("<div class='roweven'>");
            out.println("<div><b>Category ID :&nbsp; </b>"+bcb.getBookCategoryId()+"</div>");
            out.println("<div><b>Category Name :&nbsp; </b>"+bcb.getBookCategory()+"</div>");
            out.println("</div>");
            
            out.println("<div class='rowood'>");
            out.println("<div><b>Type ID :&nbsp; </b>"+btb.getBookTypeId()+"</div>");
            out.println("<div><b>Type Name :&nbsp; </b>"+btb.getBookType()+"</div>");
            out.println("</div>");
            
            out.println("<div class='roweven'>");
            out.println("<div><b>Publisher Name :&nbsp; </b>"+bb.getPublisher()+"</div>");
            out.println("<div><b>Author Name :&nbsp; </b>"+bb.getAuthor()+"</div>");
            out.println("</div>");
            
            out.println("<div class='rowood'>");
            out.println("<div><b>Year :&nbsp; </b>"+bb.getYear()+"</div>");
            out.println("<div><b>Quantity :&nbsp; </b>"+bb.getQuantity()+"</div>");
            out.println("</div>");
                                                                                    
            out.println("<div class='roweven'>");
            out.println("<div><b>Price :&nbsp; </b>"+bb.getPrice()+"</div>");
            out.println("<div><b>Fine :&nbsp; </b>"+bb.getFine()+"</div>");
            out.println("</div>");
            
            out.println("<div class='rowood'>");
            out.println("<div><b>Grace Period:&nbsp; </b>"+bb.getGracePeriod()+"</div>");
            out.println("<div><b>ISBN :&nbsp; </b>"+bb.getIsbn()+"</div>");
            out.println("</div>");
            
            out.println("<div class='roweven'>");
            out.println("<div><b>Date of Entry:&nbsp; </b>"+bb.getEntryDate()+"</div>");
            out.println("<div><b>Description :&nbsp; </b>"+bb.getBookDescription()+"</div>");
            out.println("</div>");
            
            out.println("<div class='rowood'>");
            out.println("<div><b>Entry Email:&nbsp; </b>"+bb.getEntryEmail()+"</div>");
            out.println("</div>");
            
            out.println("</div>");
        }catch(Exception e)
        {
            out.println(e);
        }finally {            
            out.close();
        }
    }
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (SQLException ex) {
            Logger.getLogger(ShowBookDetails.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (SQLException ex) {
            Logger.getLogger(ShowBookDetails.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
